home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 27.zip / BS1 part 27 / ImageMaster_d3.adf / piarc.lzh.parta / HLSubscribe.rexx < prev    next >
OS/2 REXX Batch file  |  1993-03-23  |  4KB  |  110 lines

  1. /*
  2.  * Subscribe.rexx
  3.  *
  4.  *  Written by: Pete Patterson & Ben Williams
  5.  * Last Update: February 27th, 1993
  6.  *         For: Black Belt Systems Amiga image processing software "IM"
  7.  * --------------------------------------------------------------------
  8.  *    Revision: 2.00
  9.  */
  10. call pragma('stack',20000);
  11.  
  12. if ~show('L',"rexxsupport.library") then do
  13.   if ~addlib('rexxsupport.library',0,-30,0) then do
  14.     say 'We Have A Library Problem, Unable To Load "rexxsupport.library"';
  15.     say 'Cannot operate PI Modules without this library - sorry!';
  16.     'finish';
  17.     exit 10;
  18.     end;
  19.   end;
  20.  
  21. prtnme = 'IP_Port'; /* assume Image Professional */
  22. if show('P','IP_Port') = 0 then do
  23.   if show('P','IM_Port') = 0 then do
  24.     say "Can't find image processor's ARexx port!!!"; /* not running? */
  25.     say "This script requires IP, IM or IM F/c to run!";
  26.     exit(20);
  27.     end;
  28.   else do
  29.     prtnme = 'IM_Port';
  30.     end;
  31.   end;
  32.  
  33. cmdpath = 'c:';
  34. if open(fhandle,'rexx:picmdpath','read') then
  35.   do
  36.     cmdpath = readln(fhandle);
  37.     call close(fhandle);
  38.   end
  39.  
  40. /* --------------------------------------------------------------------- */
  41. /* ------------- BEGINNING of format-specific ARexx code --------------- */
  42. /* --------------------------------------------------------------------- */
  43. address command cmdpath||'HLSubscribe c';
  44. if rc ~= 0 then do; address(prtnme); 'message "Cannot read '||fullname||' Error = '||rc||'"'; 'finish'; exit 0; end;
  45. call open(fhandle,'ram:IP_SUBSCRIBE.tmp','read'); rstring = readln(fhandle); call close(fhandle);
  46. parse var rstring width '/' height '/' depth '/' hlid '/' hlver '/' hl_name
  47. if height < 0     then do; 'message "Bad Height:' height '"'; 'finish'; exit 0; end;
  48. if height > 32767 then do; 'message "Bad Height:' height '"'; 'finish'; exit 0; end;
  49. if width  < 0     then do; 'message "Bad Width:'  width  '"'; 'finish'; exit 0; end;
  50. if width  > 32767 then do; 'message "Bad Width:'  width  '"'; 'finish'; exit 0; end;
  51.  
  52. address(prtnme);
  53. options results;
  54. 'imtofront';
  55. 'autoredraw 0';
  56. options results;
  57. 'newtargetted '||width||' '||height||' "'||hl_name||'"'
  58. if rc ~= 0 then do; 'options'; "message Can't allocate buffer!"; 'autoredraw 1'; 'finish'; exit 0; end;
  59. bnum = result;
  60. 'backin '||bnum;
  61. plugadr = result;
  62.  
  63. options;
  64. 'lockimage '||bnum;
  65. address command cmdpath||'HLSubscribe d'||plugadr;
  66. address command 'c:delete >nil: ram:IP_SUBSCRIBE.tmp';
  67. 'unlockimage '||bnum;
  68. 'imtofront';
  69. 'autoredraw 1';
  70. 'finish';
  71. exit 0;
  72.  
  73. /* --------------------------------------------------------------------- */
  74. /* ---------------- END of format-specific ARexx code ------------------ */
  75. /* --------------------------------------------------------------------- */
  76.  
  77. gimmepath:
  78.   arg fullnamegx;
  79.     tempgx = reverse(fullnamegx);
  80.     lengx = length(fullnamegx);   /* get length of string */
  81.     slashdex = index(tempgx,'/'); /* first occurance of '/' from right */
  82.     colondex = index(tempgx,':');  /* first occurance of ':' from right */
  83.     seploc = 0; /* assumes current dir, no path supplied */
  84.     if slashdex ~= 0 then do /* we assume we are in a DIR */
  85.       seploc = (lengx - slashdex)+1;
  86.       end;
  87.     else do
  88.       if colondex ~= 0 then do /* we assume we are on a device */
  89.         seploc = (lengx - colondex)+1;
  90.         end;
  91.       end;
  92.   gxname = substr(fullnamegx,seploc+1); /* if you ever need it */
  93.   gxpath = left(fullnamegx,seploc);
  94.   return(gxpath);
  95.  
  96. expandfilename:
  97.   parse arg jfile;
  98.   if index(jfile,':') = 0 then do
  99.     curdir = pragma(D);
  100.     if right(curdir,1) ~= ':' then do
  101.       if right(curdir,1) ~= '/' then do
  102.         if curdir ~= '' then do
  103.           curdir = curdir || '/';
  104.           end;
  105.         end;
  106.       end;
  107.     jfile = curdir||jfile;
  108.     end;
  109.   return(jfile);
  110.